<template>
  <view class="agreement">
    <tabTopBar :title="title" :bgColor="'transparent'" />
    <pre class="content" :style="{ height: contentHeight + 'px' }">
      {{ agreementValue }}
    </pre>
  </view>
</template>

<script setup>
import { ref, reactive } from "vue";
import apis from "@/apis/index.js";
import { onLoad } from "@dcloudio/uni-app";
import { useAppStore } from "@/store/app";

const contentHeight = ref(0);
const title = ref("");
const agreementValue = ref("");

onLoad((options) => {
  init();
  title.value = options.title;
  getUserAgreement(options.type);
});
const init = () => {
  const useStore = useAppStore();
  let navbarHeightNum = useStore.getNavBarHeight();
  let statusBarHeightNum = useStore.geStatusBarHeight();
  let windowHeight = uni.getSystemInfoSync().windowHeight;
  contentHeight.value = windowHeight - navbarHeightNum - statusBarHeightNum;
};

const getUserAgreement = (type) => {
  apis.getAgreement({ type: type }).then((res) => {
    console.log("res", res);
    if (res.code == 200) {
      agreementValue.value = res.data;
    }
  });
};
</script>

<style lang="scss" scoped>
.agreement {
  width: 100%;
  height: 100vh;
  background: linear-gradient(180deg, #172c40, #08121e);
  position: relative;
  overflow: hidden;
  box-sizing: border-box;
  .content {
    width: 100%;
    box-sizing: border-box;
    overflow-y: scroll;
    padding: 20rpx;
    white-space: pre-wrap; /* 允许换行 */
    line-height: 50rpx;
    white-space: pre-line; /* 保留换行符，将空白符序列转换为单个空格 */
    // text-indent: 0; /* 根据实际情况调整缩进值，去除开头的空格 */
  }
}
</style>
